<%--
  @author Duminda Dharmakeerthi
  @author Supun Nimesh Karunathilaka
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<head>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/dateSelector.js"></script>
<script src="${pageContext.request.contextPath}/js/landRegistration/releaseToDepartments.js" type="text/javascript"></script>

<script type="text/javascript">

    $(document).ready(function () {
        validateReleaseToDepartmentDetails();

    });

    function validateReleaseToDepartmentDetails() {
        $('#issueDate').rules("add", {
            isDateFormated:true,
            isFeatureDate:true,
            messages:{
                ageValidate:$('#pls_enter_valid_age').val()}
        });
    }


    function initialValidate() {
        initialReleaseToDepartments();
    }
    function detailValidate() {
        //        alert("detail");
    }
    function showViolationComment() {
        $('#violationComment').show();
    }

    function hideViolationComment() {
        $('#violationComment').hide();
        $('#conditionsViolationComment').val('');
    }

    function violationCommentClick() {
        if ($('#conditionsViolatedOrNot0').is(':checked')) {
            hideViolationComment();
        } else {
            showViolationComment();
        }
    }
</script>
<script type="text/javascript">
    function disableFields() {
        var fields = new Array(
                'referenceNo',
                'issueDate',
            //'folioNo',
            //'folioDate',
            //'folioLocation',
                'landUsageDescription',
                'conditionsViolatedOrNot0',
                'conditionsViolatedOrNot1',
                'conditionsViolationComment',
                'name',
                'address',
                'mobile',
                'landPhone',
                'email',
                'fax'
                );
        enableFields(fields);
    }

    $(function () {

        disableFields();
        if ($('#landMode').val() == 'DETAIL') {
            violationCommentClick();
        } else {
            hideViolationComment();
        }
    });
</script>
</head>

    <h3><s:label value="%{getText('release_to_department_details.label')}"/></h3>
    <fieldset>
    <div id="release-to-departments-details">
        <table class="width-100">
            <tr>
                <td><s:label value="%{getText('no_of_letter.label')}"/></td>
                <td><s:textfield id="referenceNo" name="alienation.referenceNo" cssClass="width-200-px"/></td>
                <td><s:label value="%{getText('date_of_letter.label')}"/> <s:label
                        value="%{getText('date_format.label')}" cssClass="date-format"/></td>
                <td><s:textfield id="issueDate" name="alienation.issueDate" onclick="selectDate('issueDate')"
                                 cssClass="width-200-px" onKeyPress="return dateNumbersOnly(event,true)"/></td>
            </tr>
            <%--
            <tr>
                <td><s:label value="%{getText('folio_no.label')}"/></td>
                <td><s:textfield id="folioNo" name="alienation.folioNumber" cssClass="width-200-px"/></td>
                <td><s:label value="%{getText('folio_date.label')}"/> <s:label value="%{getText('date_format.label')}"
                                                                               cssClass="date-format"/></td>
                <td><s:textfield id="folioDate" name="alienation.folioDate" onclick="selectDate('folioDate')"
                                 cssClass="width-200-px"/></td>
            </tr>
            <tr>
                <td><s:label value="%{getText('folio_location.label')}"/></td>
                <td colspan="3"><s:textarea id="folioLocation" name="alienation.folioLocation" rows="1"
                                            cssClass="width-595-px"/></td>
            </tr> --%>
            <tr>
                <td><s:label value="%{getText('purpose_description.label')}"/></td>
                <td colspan="3">
                    <s:textarea id="landUsageDescription" name="alienation.landUsageDescription" rows="1"
                                cssClass="width-595-px"/>
                </td>
            </tr>
            <tr>
                <td><s:label value="%{getText('conditionsViolatedOrNot.label')}"/></td>
                <td colspan="2"><s:radio id="conditionsViolatedOrNot" name="alienation.conditionsViolatedOrNot"
                                         list="#@java.util.HashMap@{'1':getText('yes.label'),'0':getText('no.label')}"
                                         onclick="violationCommentClick()"/></td>
            </tr>
            <tr id="violationComment">
                <td><s:label value="%{getText('conditionsViolationComment.label')}"/></td>
                <td colspan="3"><s:textarea id="conditionsViolationComment" name="alienation.conditionsViolationComment"
                                            rows="1"
                                            cssClass="width-595-px"/></td>
            </tr>
        </table>
    </div>
    </fieldset>

    <h3><s:label value="%{getText('department_details.label')}"/></h3>
    <fieldset>
    <div id="department-details">
        <table class="width-100">
            <tr>
                <td><s:label value="%{getText('name_of_institute.label')}"/></td>
                <td colspan="3"><s:textarea id="name" name="alienation.holder.name"
                                            cssClass="width-595-px"/></td>
            </tr>
            <tr>
                <td><s:label value="%{getText('address_of_institute.label')}"/></td>
                <td colspan="3"><s:textarea id="address" name="alienation.holder.contacts.address"
                                            cssClass="width-595-px"/></td>
            </tr>
            <tr>
                <td><s:label value="%{getText('contact_number.label')}"/></td>
                <td><s:label value="%{getText('mobile.label')}"/></td>
                <td><s:textfield id="mobile" name="alienation.holder.contacts.mobile" cssClass="width-200-px"/></td>
            </tr>
            <tr>
                <td></td>
                <td><s:label value="%{getText('land_line.label')}"/></td>
                <td><s:textfield id="landPhone" name="alienation.holder.contacts.landPhone"
                                 cssClass="width-200-px"/></td>
            </tr>
            <tr>
                <td><s:label value="%{getText('email.label')}"/></td>
                <td colspan="3"><s:textfield id="email" name="alienation.holder.contacts.email"
                                             cssClass="width-200-px"/></td>
            </tr>
            <tr>
                <td><s:label value="%{getText('fax.label')}"/></td>
                <td colspan="3"><s:textfield id="fax" name="alienation.holder.contacts.fax"
                                             cssClass="width-200-px"/></td>
            </tr>
        </table>
    </div>
    </fieldset>

    <h3><s:label value="%{getText('occupier_details.label')}"/></h3>
    <fieldset>
    <div id="occupier-details">
        <table class="width-100">
            <s:include value="encroacherDetailsPrintReport.jsp"/>
        </table>
    </div>
    </fieldset>


<s:hidden name="alienation.id"/>
<s:hidden name="alienation.holder.id"/>
<s:hidden name="alienation.holder.contacts.id"/>
<s:hidden name="alienation.holder.holderType" value="0"/>

<s:hidden id="pls_enter_reference_no" value="%{getText('pls_enter_reference_no')}"/>
<s:hidden id="pls_enter_name_of_the_land" value="%{getText('pls_enter_name_of_the_land')}"/>
<s:hidden id="pls_enter_plan_no" value="%{getText('pls_enter_plan_no')}"/>
<s:hidden id="pls_enter_lot_no" value="%{getText('pls_enter_lot_no')}"/>
<s:hidden id="pls_enter_valid_no" value="%{getText('pls_enter_valid_no')}"/>
<s:hidden id="pls_select_gn_division" value="%{getText('pls_select_gn_division')}"/>